package com.suray.wcs.res.msgparse;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Xuhang
 * @version 创建时间：2019年2月26日 下午1:22:34
 * 接受信息基础类
 */
public class ResultBase {
    /**
     * 信息校验是否正确
     */
    protected boolean isRight = false;
    /**
     * 结果接收时间
     */
    protected String retTime;
    /**
     * 任务序号
     */
    protected int taskNo;
    /**
     * 任务类型
     */
    protected int taskType;
    /**
     * 任务结果
     */
    protected int taskResult;
    /**
     * 指令命令序号
     */
    protected int cmdNo;
    /**
     * 指令执行结果
     */
    protected int cmdResult;
    /**
     * 指令执行结果 1字节
     */
    protected int cmdExecuteResult;
    /**
     * 指令结果参数
     */
    protected int cmdExecuteResultParam;

    /**
     * 设备类型
     */
    protected Integer deviceType;
    /**
     * 设备号
     */
    protected Integer deviceNo;
    /**
     * 模式
     */
    protected Integer mode;

    /**
     * 地图版本是否一致
     */
    protected Integer isSameMapVersion;
    /**
     * 状态描述
     */
    protected Integer statusMessage;

    /**
     * 1方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected int barrierAtOne;
    /**
     * 2方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected int barrierAtTwo;
    /**
     * 3方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected int barrierAtThree;
    /**
     * 4方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected int barrierAtFour;
    /**
     * 地码后缀（-100：490,0：500，100：510）
     */
    protected int offsetGroundCode;

    public Date getRetDate() {
        try {
            return new SimpleDateFormat("yyyy-M-d HH:mm:ss:S").parse(retTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        throw new IllegalArgumentException("时间解析错误");
    }

    public void setRetTime(long mills) {
        this.retTime = new SimpleDateFormat("yyyy-M-d HH:mm:ss:S").format(new Date(mills));
    }

    public boolean isRight() {
        return isRight;
    }

    public void setRight(boolean right) {
        isRight = right;
    }

    public String getRetTime() {
        return retTime;
    }

    public void setRetTime(String retTime) {
        this.retTime = retTime;
    }

    public int getTaskNo() {
        return taskNo;
    }

    public void setTaskNo(int taskNo) {
        this.taskNo = taskNo;
    }

    public int getTaskType() {
        return taskType;
    }

    public void setTaskType(int taskType) {
        this.taskType = taskType;
    }

    public int getTaskResult() {
        return taskResult;
    }

    public void setTaskResult(int taskResult) {
        this.taskResult = taskResult;
    }

    public int getCmdNo() {
        return cmdNo;
    }

    public void setCmdNo(int cmdNo) {
        this.cmdNo = cmdNo;
    }

    public int getCmdResult() {
        return cmdResult;
    }

    public void setCmdResult(int cmdResult) {
        this.cmdResult = cmdResult;
    }

    public int getCmdExecuteResult() {
        return cmdExecuteResult;
    }

    public void setCmdExecuteResult(int cmdExecuteResult) {
        this.cmdExecuteResult = cmdExecuteResult;
    }

    public int getCmdExecuteResultParam() {
        return cmdExecuteResultParam;
    }

    public void setCmdExecuteResultParam(int cmdExecuteResultParam) {
        this.cmdExecuteResultParam = cmdExecuteResultParam;
    }

    public Integer getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }

    public Integer getDeviceNo() {
        return deviceNo;
    }

    public void setDeviceNo(Integer deviceNo) {
        this.deviceNo = deviceNo;
    }

    public Integer getMode() {
        return mode;
    }

    public void setMode(Integer mode) {
        this.mode = mode;
    }

    public Integer getIsSameMapVersion() {
        return isSameMapVersion;
    }

    public void setIsSameMapVersion(Integer isSameMapVersion) {
        this.isSameMapVersion = isSameMapVersion;
    }

    public Integer getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(Integer statusMessage) {
        this.statusMessage = statusMessage;
    }

    public int getBarrierAtOne() {
        return barrierAtOne;
    }

    public void setBarrierAtOne(int barrierAtOne) {
        this.barrierAtOne = barrierAtOne;
    }

    public int getBarrierAtTwo() {
        return barrierAtTwo;
    }

    public void setBarrierAtTwo(int barrierAtTwo) {
        this.barrierAtTwo = barrierAtTwo;
    }

    public int getBarrierAtThree() {
        return barrierAtThree;
    }

    public void setBarrierAtThree(int barrierAtThree) {
        this.barrierAtThree = barrierAtThree;
    }

    public int getBarrierAtFour() {
        return barrierAtFour;
    }

    public void setBarrierAtFour(int barrierAtFour) {
        this.barrierAtFour = barrierAtFour;
    }

    public int getOffsetGroundCode() {
        return offsetGroundCode;
    }

    public void setOffsetGroundCode(int offsetGroundCode) {
        this.offsetGroundCode = offsetGroundCode;
    }

    @Override
    public String toString() {
        return "返回结果{" +
                "信息校验是否正确isRight=" + isRight +
                ", 结果接收时间retTime='" + retTime +
                ", 任务序号taskNo=" + taskNo +
                ", 任务类型taskType=" + taskType +
                ", 任务结果taskResult=" + taskResult +
                ", 指令命令序号cmdNo=" + cmdNo +
                ", 指令执行结果cmdResult=" + cmdResult +
                ", 指令执行结果cmdExecuteResult=" + cmdExecuteResult +
                ", 指令结果参数cmdExecuteResultParam=" + cmdExecuteResultParam +
                ", 设备类型deviceType=" + deviceType +
                ", 设备号deviceNo=" + deviceNo +
                ", 模式mode=" + mode +
                ", 地图版本是否一致isSameMapVersion=" + isSameMapVersion +
                ", 故障描述errorMessage=" + statusMessage +
                ", 1方向障碍物感知barrierAtOne=" + barrierAtOne +
                ", 2方向障碍物感知barrierAtTwo=" + barrierAtTwo +
                ", 3方向障碍物感知barrierAtThree=" + barrierAtThree +
                ", 4方向障碍物感知barrierAtFour=" + barrierAtFour +
                ", 地码后缀offsetGroundCode=" + offsetGroundCode +
                '}';
    }

}
